s1 = input()
s = ''
for a in s1:
    if a == '(' or a == ')'or a == '['or a == ']'or a == '{'or a == '}'or a == '<'or a == '>':
        s += a
print(s)
while '()' in s or '[]' in s or '{}' in s or '<>' in s:
    s=s.replace('()', '')
    s=s.replace('[]', '')
    s=s.replace('{}', '')
    s=s.replace('<>', '')
if s:
    print('False')
else:
    print('True')

